package com.xinfu.newproject.presenter;

import com.xinfu.newproject.bean.up_image.UpImageBean;
import com.xinfu.newproject.bean.up_image.UpImageBody;
import com.xinfu.newproject.callback.MyCallBack;
import com.xinfu.newproject.model.up_iamge.UpImageModel;
import com.xinfu.newproject.view.IView;

import io.reactivex.disposables.Disposable;

public class UpImagePresenter {
    private IView.IUpImageView mIUpImageView;

    private UpImageModel mUpImageModel;

    public UpImagePresenter(IView.IUpImageView iUpImageView) {
        this.mIUpImageView = iUpImageView;
        mUpImageModel = new UpImageModel();
    }

    /**
     * 查询报事报修
     */
    public void upImage() {

        UpImageBody upImageBody = new UpImageBody(mIUpImageView.header(), mIUpImageView.imageList(), mIUpImageView.context());

        mUpImageModel.upImage(upImageBody, new MyCallBack<UpImageBean>() {
            @Override
            public void onSuccess(UpImageBean upImageBean) {

                if (upImageBean.isSuccess()) {
                    mIUpImageView.getData(upImageBean);
                } else {
                    mIUpImageView.showToast(upImageBean.getMessage());
                }
//                mIUpImageView.showToast(upImageBean.getMessage());
            }

            @Override
            public void onError(String header, String message) {
                mIUpImageView.showToast(message);
            }

            @Override
            public void onDispose(Disposable disposable) {
                mIUpImageView.closeDispose(disposable);
            }
        });


    }


//    private Map<String, String> createParaMap() {
//        Map<String, String> paraMap = new HashMap<>();
//        paraMap.put("userName", mIRegisterView.getUserName());
//        return paraMap;
//    }

}
